﻿<?php

class GroupModel extends BaseModel
{

    var $table  = 'group';	

    var $_page_rows = 20;	
	
    /* 插入数据 */
    function insert_id()
    {    
	
	     $this->IU_Sql_Exe(array ('data' => array('sellerid'=>"0",'display'=>"0"), 'mode' => 'INSERT'));
		 
		 return $this->db->insert_id();	 
        
    }

    /* 插入数据 */
    function select_id()
    {    
		 $info = $this->S_Sql_Exe(array('fields' =>'id','conditions' =>"sellerid = '0' "));
    
		 return $info;
        
    }


    function delet_id()
    {    
		return $this->D_Sql_Exe(array ('conditions' =>"sellerid = '0' "));
       
    }

	
    /* 插入数据 */
    function post($id,$data)
    {    

		$time = time();  
		
		$this->IU_Sql_Exe(array ('data' => array('cat_id'=>"$data[cat_id]",'city'=>"$data[city]",'name'=>"$data[name]",'img'=>"$data[img]",'intro'=>"$data[intro]",'content'=>"$data[content]",'cue'=>"$data[cue]",'theysay'=>"$data[theysay]",'wesay'=>"$data[wesay]",'sellerid'=>"$data[sellerid]",'begintime'=>"$data[begintime]",'overtime'=>"$data[overtime]",'perioddate'=>"$data[perioddate]",'successnum'=>"$data[successnum]",'maxnum'=>"$data[maxnum]",'oncemax'=>"$data[oncemax]",'display'=>"$data[display]",'addtime'=>"$time"),'mode' => 'UPDATE','conditions' =>"id = '{$id}' "));   
    
        
		
    }

    function show($order='',$v='',$word='')
    {  
	     empty($order)?$order = 'addtime desc':'';
		 
   	    $conditions = " sellerid >0 ";
		 
		 foreach($word as $key => $value)
		 {

		     if($value)
		     {
		      $conditions .= " and name like '%{$value}%' ";
	  
		     }
		 }	
		  
  
	      //分页时，一定是先调用page函数，再调用S_Sql_Exe函数
		 $info['page'] = $this->Page(array('conditions' =>"{$conditions}",'url' => 'admin/?app=group&act=index&v='.$v));		
		 
		 $info['data'] = $this->S_Sql_Exe(array('fields'=> ' * ','conditions' =>"{$conditions}",'order' =>"{$order}",'limit' =>$info['page']['sql_limit']));
    
		 return $info;
   
    }
	
	
    /* 删除数据 */
    function del($id ='')
    {      
		$this->D_Sql_Exe(array ('conditions' =>"id = '{$id}' "));

        
    }

    /* 修改数据 */
    function editaction($id ='',$data = '')
    {    
		$time = time();  	      

		$this->IU_Sql_Exe(array ('data' => array('cat_id'=>"$data[cat_id]",'city'=>"$data[city]",'name'=>"$data[name]",'img'=>"$data[img]",'intro'=>"$data[intro]",'content'=>"$data[content]",'cue'=>"$data[cue]",'theysay'=>"$data[theysay]",'wesay'=>"$data[wesay]",'sellerid'=>"$data[sellerid]",'begintime'=>"$data[begintime]",'overtime'=>"$data[overtime]",'perioddate'=>"$data[perioddate]",'successnum'=>"$data[successnum]",'maxnum'=>"$data[maxnum]",'oncemax'=>"$data[oncemax]",'display'=>"$data[display]",'addtime'=>"$time"),'mode' => 'UPDATE','conditions' =>"id = '{$id}' "));  
    

    }

    /* 修改数据 */
    function editpicurl($id ='',$data = '')
    {   
     
		return $this->IU_Sql_Exe(array ('data' => array('img'=>"$data[picurl]"),'mode' => 'UPDATE','conditions' =>"id = '{$id}' "));
        
    }


    /* 修改数据 */
    function editname($id ='',$data = '')
    {   
     
		return $this->IU_Sql_Exe(array ('data' => array('name'=>"$data[name]"),'mode' => 'UPDATE','conditions' =>"id = '{$id}' "));
        
    }


    /* 修改数据 */
    function editstatus($id ='',$data = '')
    {   
     
		return $this->IU_Sql_Exe(array ('data' => array('status'=>"$data[status]"),'mode' => 'UPDATE','conditions' =>"id = '{$id}' "));
        
    }



    /* 通过id取出一条数据 */
    function oneshow($id ='')
    {    
	    

	    
	  
		 $info = $this->S_Sql_Exe(array('fields'=> '*','conditions' =>"id='{$id}' and sellerid >0 ",'return' =>'one'));
    
		 return $info;
        
    }


}




?>